<template name="livechatDepartments">
	{{#requiresPermission 'view-livechat-departments'}}
		<div class="rc-table-content">
			<form class="search-form" role="form">
				<div class="rc-input__wrapper">
					<div class="rc-input__icon">
						{{#if isReady}}
							{{> icon block="rc-input__icon-svg" icon="magnifier" }}
						{{else}}
							{{> loading }}
						{{/if}}
					</div>
					<input id="departments-filter" type="text" class="rc-input__element"
							placeholder="{{_ "Search"}}" autofocus dir="auto">
				</div>
			</form>
			<div class="results">
				{{{_ "Showing_results" departments.length}}}
			</div>

			{{#table fixed='true' onScroll=onTableScroll}}
				<thead>
					<tr>
						<th><div class="table-fake-th">{{_ "Name"}}</div></th>
						<th width="30%"><div class="table-fake-th">{{_ "Description"}}</div></th>
						<th><div class="table-fake-th">{{_ "Num_Agents"}}</div></th>
						<th><div class="table-fake-th">{{_ "Enabled"}}</div></th>
						<th width="20%"><div class="table-fake-th">{{_ "Show_on_registration_page"}}</div></th>
						<th width='40px'><div class="table-fake-th">&nbsp;</div></th>
					</tr>
				</thead>
				<tbody>
					{{#each departments}}
						<tr class="department-info row-link" data-id="{{_id}}">
							<td><div class="rc-table-wrapper">
								<div class="rc-table-info"><span class="rc-table-title">{{name}}</span></div></div></td>
							<td>{{description}}</td>
							<td>{{numAgents}}</td>
							<td>{{#if enabled}}{{_ "Yes"}}{{else}}{{_ "No"}}{{/if}}</td>
							<td>{{#if showOnRegistration}}{{_ "Yes"}}{{else}}{{_ "No"}}{{/if}}</td>
							<td>
								{{#requiresPermission 'manage-livechat-departments'}}
									<a href="#remove" class="remove-department"><i class="icon-trash"></i></a>
								{{else}}
								{{/requiresPermission}}
							</td>
						</tr>
					{{/each}}
				</tbody>
			{{/table}}
		</div>
		{{#requiresPermission 'manage-livechat-departments'}}
			<div class="rc-button__group">
				<a href="{{pathFor 'livechat-department-new'}}" class="rc-button rc-button--primary">{{_ "New_Department"}}</a>
			</div>
		{{else}}
		{{/requiresPermission}}
	{{/requiresPermission}}
</template>
